package bookManageSystem.view;
import bookManageSystem.Mat.StaticMapExample;

import javax.swing.*;
import java.awt.*;

public class UserDetailsPanel extends JPanel {
    private JLabel userIdLabel, usernameLabel, passwordLabel, phoneLabel, balanceLabel;
    private JTextField userIdField, usernameField, passwordField, phoneField;
    private JLabel balanceField; // 假设balance是只读的，所以用JLabel显示

    public UserDetailsPanel() {
        // 设置面板布局
        setLayout(new BorderLayout());

        JTextArea userDetailsArea = new JTextArea();
        userDetailsArea.setFont(new Font("微软雅黑", Font.BOLD, 25));
        userDetailsArea.setEditable(false); // 设置为不可编辑

        // 获取用户详情
        String userId = StaticMapExample.get("userId");
        String name = StaticMapExample.get("name");
        String password1 = StaticMapExample.get("password");
        String phone1 = StaticMapExample.get("phone");
        String balance1 = StaticMapExample.get("balance");

        // 检查并显示用户详情
        String userDetails = formatUserDetails(userId, name, password1, phone1, balance1);
        userDetailsArea.setText(userDetails);

        // 将文本区域添加到面板中
        add(new JScrollPane(userDetailsArea), BorderLayout.CENTER);
    }

    // 格式化用户详情的方法
    private String formatUserDetails(String userId, String name, String password, String phone, String balance) {
        return "                             用  户  详  情 \n"
                + "\n"
                + "  用户编号:"+"       "+ (userId != null ? userId : "未知") + "\n" + "\n" + "\n"
                + "  用户 名:"+"        "+ (name != null ? name : "未知") + "\n" + "\n" + "\n"
                + "  密   码:"+"        "+ (password != null ? password : "未知") + "\n"  + "\n" + "\n"
                + "  电   话:"+"        "+ (phone != null ? phone : "未知") + "\n" + "\n" + "\n"
                + "  余   额:"+"        "+(balance != null ? balance : "未知");
    }


    public void setUserDetails() {


    }
}

